package com.book.iphone;

import com.book.book.service.MessageService;
import com.book.common.utils.R;
import com.book.iphone.domain.WeiXin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 作者：青松
 * 日期： 2018/2/5
 *
 * 删除用户的系统信息
 */
@RequestMapping("/iphone")
public class SystemMessageController {
    @Autowired
    MessageService messageService;
    @RequestMapping("/DeleteSysmsg/{id}")
    @ResponseBody
    R Deletesgs(@PathVariable String id, HttpServletRequest request){

        WeiXin weiXin= (WeiXin) request.getSession().getAttribute("userInfo");
        if (weiXin==null){
            return R.error("删除失败，请重新登录");
        }
        int a=messageService.remove(Integer.valueOf(id));
        if (a!=1){
            return R.error("删除失败，稍后再试");
        }else {
            return R.ok("删除成功");
        }
    }
}
